﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Objects.DataClasses;
using Common.Model;
using Common.DataAccess;

namespace Common.ServiceLogic
{
    public class GenericEntityReaderServiceLogic<E, DA> : IGenericEntityReaderServiceLogic<E>
        where E : IObjectWithChangeTracker
        where DA : IGenericEntityReaderDataAccess<E>, new()
    {

        #region IEntityReaderService<E,C,EV> Members

        DA _dataAccess;
        public DA DataAccess
        {
            get
            {
                if (_dataAccess == null)
                {
                    _dataAccess = new DA();
                }
                return _dataAccess;
            }
        }

        public virtual List<E> ReadEntities()
        {
            return DataAccess.ReadEntities();
        }

        public virtual List<E> ReadEntitiesByParameter(IObjectWithChangeTracker entityObject)
        {
            return DataAccess.ReadEntitiesByParameter(entityObject);
        }

        #endregion
    }
}